﻿Public Class HotelAndGuestHouse
    Dim FloorMg As FloorManagemant
    Dim Reservation As MainReservation
    Dim Service As MainService
    Dim FinanceReport As MainFinanceReport
    Dim UserManagement As UCDepartment

    Dim DA_USER_PERMISION As New DSUserManagermentTableAdapters.V_USER_MENU_PERMISIONTableAdapter
    Dim formLogin As frmLoginChackTravoth
    Sub New()

        ' This call is required by the Windows Form Designer.
        InitializeComponent()
        CreateInitForm()
        CheckPermistionOnForm()
        ChangeInputLanguageBar()
        ' Add any initialization after the InitializeComponent() call.

    End Sub
    Sub New(ByVal formLogin As frmLoginChackTravoth)

        ' This call is required by the Windows Form Designer.
        InitializeComponent()
        Me.formLogin = formLogin
        CreateInitForm()
        CheckPermistionOnForm()
        ChangeInputLanguageBar()
        ' Add any initialization after the InitializeComponent() call.

    End Sub
    Private Sub CreateInitForm()
        FloorMg = New FloorManagemant
        Application.DoEvents()
        formLogin.UpdateLabelStatus("Creating patient information 1.", True)
        Reservation = New MainReservation
        Application.DoEvents()
        formLogin.UpdateLabelStatus("Creating patient information 1.", True)
        Service = New MainService
        Application.DoEvents()

        formLogin.UpdateLabelStatus("Creating patient information 1.", True)
        FinanceReport = New MainFinanceReport
        Application.DoEvents()
        formLogin.UpdateLabelStatus("Creating patient information 1.", True)
        UserManagement = New UCDepartment
        formLogin.UpdateLabelStatus("Creating patient information 1.", True)
        Application.DoEvents()
    End Sub
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        GeneralAddControl(uiPanel5Container, Reservation, "កាក្រប់គ្រង ភ្ញៀវស្នាក់នៅផ្ទេះសំណាក់")
        MainHotel = Me
        LblUser.Text = "អ្នកប្រើប្រាស់ : " & USER_NAME

    End Sub
    Sub GeneralAddControl(ByVal PMainContainer As Janus.Windows.UI.Dock.UIPanelInnerContainer, ByVal UI As UserControl, ByVal Info As String)
        Me.Cursor = Cursors.WaitCursor
        PMainContainer.Controls.Clear()

        PMainContainer.AutoScrollMinSize = New Size(UI.Width, UI.Height)
        UI.Dock = DockStyle.Fill
        PMainContainer.Controls.Add(UI)
        PMainContainer.AutoScroll = True
        Me.Cursor = Cursors.Default
        uiPanel5.Text = Info
    End Sub

   

    Private Sub ButtonBar1_ItemClick_1(ByVal sender As System.Object, ByVal e As Janus.Windows.ButtonBar.ItemEventArgs) Handles GroupPanelHotel.ItemClick
        Select Case e.Item.Key
            Case "Reservation"
                GeneralAddControl(uiPanel5Container, Reservation, "កាក្រប់គ្រង ភ្ញៀវស្នាក់នៅផ្ទេះសំណាក់")
            Case "FloorManagement"
                GeneralAddControl(uiPanel5Container, FloorMg, "កាក្រប់គ្រង បន្ទប់ និង ជាន់ របស់ផ្ទេះសំណាក់")
            Case "FinanceReport"
                GeneralAddControl(uiPanel5Container, FinanceReport, "របាយការណ៏ និង ភ្ញៀវស្នាកនៅ")
            Case "Service"
                GeneralAddControl(uiPanel5Container, Service, "គ្រប់ក្រង់ សេវាកម្ម")
            Case "UserManagement"
                GeneralAddControl(uiPanel5Container, UserManagement, "គ្រប់ក្រង់ អ្នកប្រើប្រាស់")
                UserManagement.InitDepartment()
            Case "CloseSystem"
                If MessageBox.Show("Do you want to exit this application?", "Exit", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
                    Application.Exit()
                End If

        End Select
    End Sub

    Private Sub CheckPermistionOnForm()
        Dim TblMenuPermistion As DataTable = DA_USER_PERMISION.GetDataByGetMenuPermissionUserName(USER_NAME)
        Dim indexBar As Integer
        Dim indexSubBar As Integer
        Dim indexMenu As Integer
        ' Check Permistion in Tab patient Information....
        For indexBar = 0 To GroupPanelHotel.Groups.Count - 1
            For indexSubBar = 0 To GroupPanelHotel.Groups(indexBar).Items.Count - 1
                For indexMenu = 0 To TblMenuPermistion.Rows.Count - 1
                    Application.DoEvents()
                    'MsgBox(BottonBarMain.Groups(indexBar).Items(indexSubBar).Key & "    " & tblPermistion.Rows(indexMenu).Item(0))                    
                    If GroupPanelHotel.Groups(indexBar).Items(indexSubBar).Key = TblMenuPermistion.Rows(indexMenu).Item("MenuKey") Then
                        'Login.UpdateLabelStatus("Checking menu name " & BottonBarMain.Groups(indexBar).Items(indexSubBar).Text, True)
                        'Application.DoEvents()
                        GroupPanelHotel.Groups(indexBar).Items(indexSubBar).Enabled = Janus.Windows.UI.InheritableBoolean.True
                    End If
                Next
            Next
        Next



        '' Check Permision in  tab patient consultation ...............
        'For indexBar = 0 To Parameter.Groups.Count - 1
        '    For indexSubBar = 0 To Parameter.Groups(indexBar).Items.Count - 1
        '        For indexMenu = 0 To TblMenuPermistion.Rows.Count - 1
        '            Application.DoEvents()
        '            'MsgBox(BottonBarMain.Groups(indexBar).Items(indexSubBar).Key & "    " & tblPermistion.Rows(indexMenu).Item(0))                    
        '            If Parameter.Groups(indexBar).Items(indexSubBar).Key = TblMenuPermistion.Rows(indexMenu).Item("MenuKey") Then
        '                'Login.UpdateLabelStatus("Checking menu name " & BottonBarMain.Groups(indexBar).Items(indexSubBar).Text, True)
        '                'Application.DoEvents()
        '                Parameter.Groups(indexBar).Items(indexSubBar).Enabled = Janus.Windows.UI.InheritableBoolean.True
        '            End If
        '        Next
        '    Next
        'Next

        ''Check Permision in  tab patient System ...............
        'For indexBar = 0 To ButonUserManage.Groups.Count - 1
        '    For indexSubBar = 0 To ButonUserManage.Groups(indexBar).Items.Count - 1
        '        For indexMenu = 0 To TblMenuPermistion.Rows.Count - 1
        '            Application.DoEvents()
        '            'MsgBox(BottonBarMain.Groups(indexBar).Items(indexSubBar).Key & "    " & tblPermistion.Rows(indexMenu).Item(0))                    
        '            If ButonUserManage.Groups(indexBar).Items(indexSubBar).Key = TblMenuPermistion.Rows(indexMenu).Item("MenuKey") Then
        '                'Login.UpdateLabelStatus("Checking menu name " & BottonBarMain.Groups(indexBar).Items(indexSubBar).Text, True)
        '                'Application.DoEvents()
        '                ButonUserManage.Groups(indexBar).Items(indexSubBar).Enabled = Janus.Windows.UI.InheritableBoolean.True
        '            End If
        '        Next
        '    Next
        'Next

        ''check Permision in tab Inventory
        'For indexBar = 0 To Inventory.Groups.Count - 1
        '    For indexSubBar = 0 To Inventory.Groups(indexBar).Items.Count - 1
        '        For indexMenu = 0 To TblMenuPermistion.Rows.Count - 1
        '            Application.DoEvents()
        '            'MsgBox(BottonBarMain.Groups(indexBar).Items(indexSubBar).Key & "    " & tblPermistion.Rows(indexMenu).Item(0))                    
        '            If Inventory.Groups(indexBar).Items(indexSubBar).Key = TblMenuPermistion.Rows(indexMenu).Item("MenuKey") Then
        '                'Login.UpdateLabelStatus("Checking menu name " & BottonBarMain.Groups(indexBar).Items(indexSubBar).Text, True)
        '                'Application.DoEvents()
        '                Inventory.Groups(indexBar).Items(indexSubBar).Enabled = Janus.Windows.UI.InheritableBoolean.True
        '            End If
        '        Next
        '    Next
        'Next
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        LblDate.Text = "ម៉ោង : " & Format(Now, "dd/MM/yyyy hh:mm:ss tt")
    End Sub
End Class
